package com.ict.web.controller.yzq;

import com.ict.common.annotation.Log;
import com.ict.common.core.controller.BaseController;
import com.ict.common.core.domain.AjaxResult;
import com.ict.common.core.page.TableDataInfo;
import com.ict.common.enums.BusinessType;
import com.ict.web.domain.LastCheck;
import com.ict.web.dto.LastCheckAddDto;
import com.ict.web.dto.LastCheckEditDto;
import com.ict.web.service.ILastCheckService;
import com.ict.web.vo.LastCheckDetailsVo;
import com.ict.web.vo.LastCheckTimeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 终验备案管理Controller
 *
 * @author ruoyi
 * @date 2022-02-14
 */
@Api(tags = "终验备案管理")
@RestController
@RequestMapping("/lastCheck")
public class LastCheckController extends BaseController
{
    @Autowired
    private ILastCheckService lastCheckService;

    /**
     * 查询终验备案管理列表
     */
//    @PreAuthorize("@ss.hasPermi('web:lastCheck:list')")
    @ApiOperation("查询终验备案管理列表")
    @GetMapping("/list")
    public TableDataInfo list(LastCheck lastCheck)
    {
        startPage();
        List<LastCheck> list = lastCheckService.selectLastCheckList(lastCheck);
        return getDataTable(list);
    }

    /**
     * 获取终验备案管理详细信息
     */
//    @PreAuthorize("@ss.hasPermi('web:lastCheck:query')")
    @ApiOperation("获取终验备案管理详细信息")
    @GetMapping(value = "/{lastCheckId}")
    public LastCheckDetailsVo getInfo(@PathVariable("lastCheckId") Long lastCheckId)
    {
        return lastCheckService.selectLastCheckByLastCheckId(lastCheckId);
    }

    /**
     * 新增终验备案管理
     */
//    @PreAuthorize("@ss.hasPermi('web:lastCheck:add')")
    @ApiOperation("新增终验备案管理")
    @Log(title = "终验备案管理", businessType = BusinessType.INSERT)
    @PostMapping
    public Long add(@RequestBody LastCheckAddDto dto)
    {
        return lastCheckService.insertLastCheck(dto);
    }

    /**
     * 修改终验备案管理
     */
//    @PreAuthorize("@ss.hasPermi('web:lastCheck:edit')")
    @ApiOperation("修改终验备案管理")
    @Log(title = "终验备案管理", businessType = BusinessType.UPDATE)
    @PutMapping("/edit/{lastCheckId}")
    public AjaxResult edit(@RequestBody LastCheckAddDto dto, @PathVariable Long lastCheckId)
    {
        return toAjax(lastCheckService.updateLastCheck(dto,lastCheckId));
    }

    /**
     * 删除终验备案管理
     */
//    @PreAuthorize("@ss.hasPermi('web:lastCheck:remove')")
    @ApiOperation("删除终验备案管理")
    @Log(title = "终验备案管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{lastCheckId}")
    public AjaxResult remove(@PathVariable Long lastCheckId)
    {
        return toAjax(lastCheckService.deleteLastCheckByLastCheckId(lastCheckId));
    }

    @ApiOperation("查询终验备案创建时间和考核结束时间")
    @GetMapping("getLastCheckCreateTime/{proId}")
    public LastCheckTimeVo getLastCheckCreateTime(@PathVariable Long proId){
        return lastCheckService.getLastCheckCreateTime(proId);
    }
}
